﻿using HomeCareLibrary.AppService;
using HomeCareLibrary.Constants;
using HomeCareLibrary.Core.DataContracts;
using HomeCareLibrary.Core.Dtos;
using HomeCareLibrary.Filters;
using HomeCareLibrary.Models;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Web.Mvc;
using System.Web.Script.Serialization;



namespace HomeCareLibrary.Controllers
{
    //[HybridAuthorize] //comment on(5.2.2014)
    public class MttController : BaseController
    {
        //
        // GET: /Mtt/

        public ActionResult tasks(Int32? year, Int32? month)
        {
            //Session[SessionConstants.MODE] = ApplicationModeConstants.ANDROID_APP; //Only for Testing

            #region[for Android Testing]

            ViewBag.sessionIds = "Session Id: " + Session.SessionID.ToString() + ", " + SessionConstants.HOME_NUMBER + "=" + Session[SessionConstants.HOME_NUMBER] + ", " + SessionConstants.USER_ID + "=" + Session[SessionConstants.USER_ID] + ", " + SessionConstants.USER_NAME + "=" + Session[SessionConstants.USER_NAME] + ", " + SessionConstants.PASSWORD + "=" + Session[SessionConstants.PASSWORD] + ", " + SessionConstants.MODE + "=" + Session[SessionConstants.MODE] + ", " + SessionConstants.ACTIVITY_TYPE + "=" + Session[SessionConstants.ACTIVITY_TYPE] + ", " + SessionConstants.PROMO_CODE + "=" + Session[SessionConstants.PROMO_CODE] + ", " + SessionConstants.SPONSOR_DETAILS + "=" + Session[SessionConstants.SPONSOR_DETAILS];

            string str = null;
            foreach (string key in Session.Keys)
            {
                try
                {
                    if (Session[key] != null)
                    {

                        str += string.Format("{0}: {1}<br />", key, Session[key].ToString());
                    }
                }
                catch
                { }
            }
            ViewBag.getSession = str;

            Request.InputStream.Position = 0;
            StreamReader postedVariableStream = new StreamReader(Request.InputStream);
            string postedVariableJsonString = postedVariableStream.ReadToEnd();
            ViewBag.JsonString = postedVariableJsonString;


            string getContentType = Request.ContentType;
            ViewBag.ContentType = getContentType;

            string getRequestUrl = Request.Url.ToString();
            ViewBag.Url = getRequestUrl;

            #endregion

            TasksAppService service = new TasksAppService();
            try
            {
                TempData["Error"] = "There is no error in tasks and Session value is" + Session[SessionConstants.USER_ID];


                if (Session[SessionConstants.USER_ID] != null)
                {
                    Int32 userId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());
                    Int32 homeNumber = 1;

                    DataRepository entities = new DataRepository();
                    if (Session[SessionConstants.HOME_NUMBER] == null || Convert.ToInt32(Session[SessionConstants.HOME_NUMBER]) == 0)
                    {
                        var getHomeNumber = entities.getMultipleHomesByUserID(userId);
                        homeNumber = Convert.ToInt32(getHomeNumber);
                        Session[SessionConstants.HOME_NUMBER] = homeNumber;
                    }
                    else
                    {
                        homeNumber = Convert.ToInt32(Session[SessionConstants.HOME_NUMBER].ToString());
                    }

                    if (month == null)
                    {
                        if (Session[SessionConstants.TASK_MONTH] == null)
                        {
                            Session[SessionConstants.TASK_MONTH] = System.DateTime.Now.Month.ToString();
                        }

                    }
                    else
                    {

                        Session[SessionConstants.TASK_MONTH] = Convert.ToString(month); //assign value to session
                    }

                    if (year == null)
                    {

                        if (Session[SessionConstants.TASK_YEAR] == null)
                        {

                            Session[SessionConstants.TASK_YEAR] = System.DateTime.Now.Year.ToString();
                        }
                    }
                    else
                    {

                        Session[SessionConstants.TASK_YEAR] = Convert.ToString(year); //assign value to session
                    }


                    //Call Task App Service (GetTasksList)
                    TasksRequest objTasksRequest = new TasksRequest();
                    objTasksRequest.UserId = userId;
                    objTasksRequest.HomeNumber = Convert.ToByte(homeNumber);
                    objTasksRequest.Month = Convert.ToByte(Session[SessionConstants.TASK_MONTH]);
                    objTasksRequest.Year = Convert.ToInt16(Session[SessionConstants.TASK_YEAR]);

                    var tasks = service.GetTasksList(objTasksRequest);

                    ViewBag.getMonths = new SelectList(getMonths(), "Value", "Text", Session[SessionConstants.TASK_MONTH]);
                    ViewBag.getYear = new SelectList(getYears(Convert.ToInt32(System.DateTime.Now.Year.ToString())), "Value", "Text", Session[SessionConstants.TASK_YEAR]);
                    ViewBag.getDisplay = new SelectList(getDisplay(), "Value", "Text","");
                    ViewBag.getSortBy = new SelectList(getSortBy(), "Value", "Text",1);

                    PersonalisationAppService objPersonalisationAppService = new PersonalisationAppService();
                    GetUserHomeRequest objGetUserHomeRequest = new GetUserHomeRequest();
                    objGetUserHomeRequest.UserId = userId;
                    var getUserHome1 = objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest);
                    if (getUserHome1.Count == 1)
                    {
                        ViewBag.getSingleHomeName = getUserHome1.FirstOrDefault().home_name;
                        ViewBag.getSingleHomeValue = getUserHome1.FirstOrDefault().home_number;
                    }
                    else
                    {
                        ViewBag.getSingleHomeName = "";
                        ViewBag.getSingleHomeValue = "";
                        ViewBag.getHomeName = new SelectList(getUserHome1, "home_number", "home_name", homeNumber);
                    }
                    if (tasks.Count() == 0)
                    {
                        ViewBag.noRecords = "You have no Tasks for this month based on your personalization.";
                    }


                    // To Get User Home Name
              
                    objGetUserHomeRequest.UserId = userId;
                    var getUserHome = (from d in objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest) where d.home_number == homeNumber select d).SingleOrDefault();

                    TasksModel objTasksModel = new TasksModel();
                    var taskModels = new List<TasksModel>();
                    objTasksModel.TasksList = tasks.OrderByDescending(x => x.priority);
                    objTasksModel.selectedmonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(Session[SessionConstants.TASK_MONTH]));
                    objTasksModel.selectedyear = Convert.ToInt32(Session[SessionConstants.TASK_YEAR]);

                    if (getUserHome == null)
                    {
                        objTasksModel.homename = "";
                    }
                    else
                    {
                        objTasksModel.homename = getUserHome.home_name;
                    }

                    return PartialView("tasks", objTasksModel);
                }
                else
                {
                    //In Js function (mtt.js) we redirect blank content to Login Page.
                    return Content("");
                }
            }
            catch (Exception err)
            {
                TempData["Error"] = err.Message;

                //return RedirectToAction("Login", "Home");
                return Content("");
            }
        }

        public ActionResult TaskDisplay(Int32? homeNumber, string display, string sortBy)
        {
            TasksAppService service = new TasksAppService();
            if (Session[SessionConstants.USER_ID] != null)
            {
                Session[SessionConstants.HOME_NUMBER] = homeNumber;
                Int32 userId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());
                if (Session[SessionConstants.TASK_YEAR] == null)
                    Session[SessionConstants.TASK_YEAR] = System.DateTime.Now.Year.ToString();
                if (Session[SessionConstants.TASK_MONTH] == null)
                    Session[SessionConstants.TASK_MONTH] = System.DateTime.Now.Month.ToString();
                TasksRequest objTasksRequest = new TasksRequest();
                objTasksRequest.UserId = userId;
                objTasksRequest.HomeNumber = Convert.ToByte(homeNumber);
                objTasksRequest.Month = Convert.ToByte(Session[SessionConstants.TASK_MONTH]);
                objTasksRequest.Year = Convert.ToInt16(Session[SessionConstants.TASK_YEAR]);

                var tasks = service.GetTasksList(objTasksRequest);
               
                TasksModel objTasksModel = new TasksModel();
                var taskModels = new List<TasksModel>();
                if (display != "")
                    objTasksModel.TasksList = tasks.Where(c => c.done_or_not == display);
                else
                    objTasksModel.TasksList = tasks;

                switch (sortBy) { 
                    case "1":
                        objTasksModel.TasksList = objTasksModel.TasksList.OrderByDescending(p => p.priority);
                        break;
                    case "2":
                        objTasksModel.TasksList = objTasksModel.TasksList.OrderBy(p => p.feature_name);
                        break;
                    case "4":
                        objTasksModel.TasksList = objTasksModel.TasksList.OrderBy(p => p.type);
                        break;
                    default:
                        objTasksModel.TasksList = objTasksModel.TasksList;
                        break;


                }
               
                ViewBag.getMonths = new SelectList(getMonths(), "Value", "Text", Session[SessionConstants.TASK_MONTH]);
                ViewBag.getYear = new SelectList(getYears(Convert.ToInt32(System.DateTime.Now.Year.ToString())), "Value", "Text", Session[SessionConstants.TASK_YEAR]);
                ViewBag.getDisplay = new SelectList(getDisplay(), "Value", "Text", display);
                ViewBag.getSortBy = new SelectList(getSortBy(), "Value", "Text",sortBy);

                PersonalisationAppService objPersonalisationAppService = new PersonalisationAppService();
                GetUserHomeRequest objGetUserHomeRequest = new GetUserHomeRequest();
                objGetUserHomeRequest.UserId = userId;
                var getUserHome1 = objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest);
                ViewBag.getHomeName = new SelectList(getUserHome1, "home_number", "home_name", homeNumber);
                if (getUserHome1.Count == 1)
                {
                    ViewBag.getSingleHomeName = getUserHome1.FirstOrDefault().home_name;
                    ViewBag.getSingleHomeValue = getUserHome1.FirstOrDefault().home_number;
                }
                else
                {
                    ViewBag.getSingleHomeName = "";
                    ViewBag.getSingleHomeValue = "";
                    ViewBag.getHomeName = new SelectList(getUserHome1, "home_number", "home_name", homeNumber);
                }
                if (objTasksModel.TasksList.Count() == 0)
                {
                    ViewBag.noRecords = "You have no Tasks for this month based on your personalization.";
                }
                objTasksModel.selectedmonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(Session[SessionConstants.TASK_MONTH]));
                objTasksModel.selectedyear = Convert.ToInt32(Session[SessionConstants.TASK_YEAR]);
                var getUserHome = (from d in objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest) where d.home_number == homeNumber select d).SingleOrDefault();
                if (getUserHome == null)
                {
                    objTasksModel.homename = "";
                }
                else
                {
                    objTasksModel.homename = getUserHome.home_name;
                }
                return PartialView("tasks", objTasksModel);
            }
            else
            {
                return Json("", JsonRequestBehavior.AllowGet);
            }
        }

        public ActionResult TasksView()
        {

            //if (Request.IsAjaxRequest())
            //{
            //    return PartialView("TasksView");
            //}
            //else
            //{

            //Session[SessionConstants.MODE] = ApplicationModeConstants.IPHONE_APP; //Only for Testing


            string str = null;
            foreach (string key in Session.Keys)
            {
                try
                {
                    if (Session[key] != null)
                    {

                        str += string.Format("{0}: {1}<br />", key, Session[key].ToString());
                    }
                }
                catch
                { }
            }
            ViewBag.getSession = str;

            ViewBag.sessionIds = "Session Id: " + Session.SessionID.ToString() + ", " + SessionConstants.USER_ID + "=" + Session[SessionConstants.USER_ID] + ", " + SessionConstants.USER_NAME + "=" + Session[SessionConstants.USER_NAME] + ", " + SessionConstants.PASSWORD + "=" + Session[SessionConstants.PASSWORD] + ", " + SessionConstants.MODE + "=" + Session[SessionConstants.MODE] + ", " + SessionConstants.ACTIVITY_TYPE + "=" + Session[SessionConstants.ACTIVITY_TYPE] + ", " + SessionConstants.PROMO_CODE + "=" + Session[SessionConstants.PROMO_CODE] + ", " + SessionConstants.SPONSOR_DETAILS + "=" + Session[SessionConstants.SPONSOR_DETAILS];

            Request.InputStream.Position = 0;
            StreamReader postedVariableStream = new StreamReader(Request.InputStream);
            string postedVariableJsonString = postedVariableStream.ReadToEnd();
            ViewBag.JsonString = postedVariableJsonString;

            string getContentType = Request.ContentType;
            ViewBag.ContentType = getContentType;

            string getRequestUrl = Request.Url.ToString();
            ViewBag.Url = getRequestUrl;

            return View();
            // }
        }

        public ActionResult TipsView()
        {
            ViewBag.sessionIds = "Session Id: " + Session.SessionID.ToString() + ", " + SessionConstants.USER_ID + "=" + Session[SessionConstants.USER_ID] + ", " + SessionConstants.USER_NAME + "=" + Session[SessionConstants.USER_NAME] + ", " + SessionConstants.PASSWORD + "=" + Session[SessionConstants.PASSWORD] + ", " + SessionConstants.MODE + "=" + Session[SessionConstants.MODE] + ", " + SessionConstants.ACTIVITY_TYPE + "=" + Session[SessionConstants.ACTIVITY_TYPE] + ", " + SessionConstants.PROMO_CODE + "=" + Session[SessionConstants.PROMO_CODE] + ", " + SessionConstants.SPONSOR_DETAILS + "=" + Session[SessionConstants.SPONSOR_DETAILS];

            string str = null;
            foreach (string key in Session.Keys)
            {
                try
                {
                    if (Session[key] != null)
                    {

                        str += string.Format("{0}: {1}<br />", key, Session[key].ToString());
                    }
                }
                catch
                { }
            }
            ViewBag.getSession = str;

            Request.InputStream.Position = 0;
            StreamReader postedVariableStream = new StreamReader(Request.InputStream);
            string postedVariableJsonString = postedVariableStream.ReadToEnd();
            ViewBag.JsonString = postedVariableJsonString;

            string getContentType = Request.ContentType;
            ViewBag.ContentType = getContentType;

            string getRequestUrl = Request.Url.ToString();
            ViewBag.Url = getRequestUrl;

            return View();
        }

        public ActionResult tips()
        {
            #region[for Android Testing]
            string str = null;
            foreach (string key in Session.Keys)
            {
                try
                {
                    if (Session[key] != null)
                    {

                        str += string.Format("{0}: {1}<br />", key, Session[key].ToString());
                    }
                }
                catch
                { }
            }
            ViewBag.getSession = str;

            ViewBag.sessionIds = "Session Id: " + Session.SessionID.ToString() + ", " + SessionConstants.USER_ID + "=" + Session[SessionConstants.USER_ID] + ", " + SessionConstants.USER_NAME + "=" + Session[SessionConstants.USER_NAME] + ", " + SessionConstants.PASSWORD + "=" + Session[SessionConstants.PASSWORD] + ", " + SessionConstants.MODE + "=" + Session[SessionConstants.MODE] + ", " + SessionConstants.ACTIVITY_TYPE + "=" + Session[SessionConstants.ACTIVITY_TYPE] + ", " + SessionConstants.PROMO_CODE + "=" + Session[SessionConstants.PROMO_CODE] + ", " + SessionConstants.SPONSOR_DETAILS + "=" + Session[SessionConstants.SPONSOR_DETAILS];

            Request.InputStream.Position = 0;
            StreamReader postedVariableStream = new StreamReader(Request.InputStream);
            string postedVariableJsonString = postedVariableStream.ReadToEnd();
            ViewBag.JsonString = postedVariableJsonString;

            string getContentType = Request.ContentType;
            ViewBag.ContentType = getContentType;

            string getRequestUrl = Request.Url.ToString();
            ViewBag.Url = getRequestUrl;

            #endregion
            TipsAppService service = new TipsAppService();
            try
            {
                TempData["Error"] = "There is no error in tips and Session value is" + Session[SessionConstants.USER_ID];
                if (Session[SessionConstants.USER_ID] != null)
                {
                    DataRepository entities = new DataRepository();
                    Int32 userId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());
                    Int32 homeNumber = 1;

                    if (Session[SessionConstants.HOME_NUMBER] == null || Convert.ToInt32(Session[SessionConstants.HOME_NUMBER]) == 0)
                    {
                        var getHomeNumber = entities.getMultipleHomesByUserID(userId);
                        homeNumber = Convert.ToInt32(getHomeNumber);
                        Session[SessionConstants.HOME_NUMBER] = homeNumber;
                    }
                    else
                        homeNumber = Convert.ToInt32(Session[SessionConstants.HOME_NUMBER].ToString());

                    string getRequestedMonth = System.DateTime.Now.Month.ToString();
                    string getRequestedYear = System.DateTime.Now.Year.ToString();

                    TasksRequest objTipsRequest = new TasksRequest();
                    objTipsRequest.UserId = userId;
                    objTipsRequest.HomeNumber = Convert.ToByte(homeNumber);
                    objTipsRequest.Month = Convert.ToByte(getRequestedMonth);
                    objTipsRequest.Year = Convert.ToInt16(getRequestedYear);

                    var tips = service.GetTipsList(objTipsRequest);

                    if (tips.Count() == 0)
                    {
                        ViewBag.noRecords = "You have no Tips for this month based on your personalization.";
                    }


                    // To Get User Home Name
                    PersonalisationAppService objPersonalisationAppService = new PersonalisationAppService();
                    GetUserHomeRequest objGetUserHomeRequest = new GetUserHomeRequest();
                    objGetUserHomeRequest.UserId = userId;
                    var getUserHome = (from d in objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest) where d.home_number == homeNumber select d).SingleOrDefault();
                    var getUserHome1 = objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest);
                    if (getUserHome1.Count > 1)
                    {
                        ViewBag.getSingleHomeName = getUserHome1.FirstOrDefault().home_name;
                        ViewBag.getHomeNameTip = new SelectList(getUserHome1, "home_number", "home_name", homeNumber);
                    }
                    else
                    {
                        ViewBag.getSingleHomeName = null;
                        ViewBag.getHomeNameTip = new SelectList(getUserHome1, "home_number", "home_name", homeNumber);
                    }

                    TipsModel objTipsModel = new TipsModel();
                    var taskModels = new List<TipsModel>();
                    objTipsModel.listTipsModel = tips;
                    objTipsModel.selectedmonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(getRequestedMonth));
                    objTipsModel.selectedyear = Convert.ToInt32(getRequestedYear);

                    if (getUserHome == null)
                    {
                        objTipsModel.homename = "";
                    }
                    else
                    {
                        objTipsModel.homename = getUserHome.home_name;
                    }


                    return PartialView("tips", objTipsModel);

                }
                else
                {
                    //In Js function (mtt.js) we redirect blank content to Login Page.   
                    return Content("");
                }
            }
            catch (Exception err)
            {
                TempData["Error"] = err.Message;

                //return RedirectToAction("Login", "Home");
                return Content("");
            }
        }

        public ActionResult TipsByHome(Int32? homeNumber)
        {
            TipsAppService service = new TipsAppService();
            try
            {
                
                if (Session[SessionConstants.USER_ID] != null)
                {
                    Session[SessionConstants.HOME_NUMBER] = homeNumber;
                    DataRepository entities = new DataRepository();
                    Int32 userId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());

                    string getRequestedMonth = System.DateTime.Now.Month.ToString();
                    string getRequestedYear = System.DateTime.Now.Year.ToString();

                    TasksRequest objTipsRequest = new TasksRequest();
                    objTipsRequest.UserId = userId;
                    objTipsRequest.HomeNumber = Convert.ToByte(homeNumber);
                    objTipsRequest.Month = Convert.ToByte(getRequestedMonth);
                    objTipsRequest.Year = Convert.ToInt16(getRequestedYear);

                    var tips = service.GetTipsList(objTipsRequest);

                    if (tips.Count() == 0)
                    {
                        ViewBag.noRecords = "You have no Tips for this month based on your personalization.";
                    }


                    // To Get User Home Name
                    PersonalisationAppService objPersonalisationAppService = new PersonalisationAppService();
                    GetUserHomeRequest objGetUserHomeRequest = new GetUserHomeRequest();
                    objGetUserHomeRequest.UserId = userId;
                    var getUserHome = (from d in objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest) where d.home_number == homeNumber select d).SingleOrDefault();
                    var getUserHome1 = objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest);
                    if (getUserHome1.Count > 1)
                    {
                        ViewBag.getSingleHomeName = getUserHome1.FirstOrDefault().home_name;
                        ViewBag.getHomeNameTip = new SelectList(getUserHome1, "home_number", "home_name", homeNumber);
                    }
                    else
                    {
                        ViewBag.getSingleHomeName = null;
                        ViewBag.getHomeNameTip = new SelectList(getUserHome1, "home_number", "home_name");
                    }

                    TipsModel objTipsModel = new TipsModel();
                    var taskModels = new List<TipsModel>();
                    objTipsModel.listTipsModel = tips;
                    objTipsModel.selectedmonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(getRequestedMonth));
                    objTipsModel.selectedyear = Convert.ToInt32(getRequestedYear);

                    if (getUserHome == null)
                    {
                        objTipsModel.homename = "";
                    }
                    else
                    {
                        objTipsModel.homename = getUserHome.home_name;
                    }


                    return PartialView("tips", objTipsModel);

                }
                else
                {
                    //In Js function (mtt.js) we redirect blank content to Login Page.   
                    return Json("", JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception err)
            {
                

                //return RedirectToAction("Login", "Home");
                return Content("");
            }
        }

        public ActionResult ideas()
        {

            #region[for Android Testing]
            string str = null;
            foreach (string key in Session.Keys)
            {
                try
                {
                    if (Session[key] != null)
                    {

                        str += string.Format("{0}: {1}<br />", key, Session[key].ToString());
                    }
                }
                catch
                { }
            }
            ViewBag.getSession = str;

            ViewBag.sessionIds = "Session Id: " + Session.SessionID.ToString() + ", " + SessionConstants.USER_ID + "=" + Session[SessionConstants.USER_ID] + ", " + SessionConstants.USER_NAME + "=" + Session[SessionConstants.USER_NAME] + ", " + SessionConstants.PASSWORD + "=" + Session[SessionConstants.PASSWORD] + ", " + SessionConstants.MODE + "=" + Session[SessionConstants.MODE] + ", " + SessionConstants.ACTIVITY_TYPE + "=" + Session[SessionConstants.ACTIVITY_TYPE] + ", " + SessionConstants.PROMO_CODE + "=" + Session[SessionConstants.PROMO_CODE] + ", " + SessionConstants.SPONSOR_DETAILS + "=" + Session[SessionConstants.SPONSOR_DETAILS];

            Request.InputStream.Position = 0;
            StreamReader postedVariableStream = new StreamReader(Request.InputStream);
            string postedVariableJsonString = postedVariableStream.ReadToEnd();
            ViewBag.JsonString = postedVariableJsonString;

            string getContentType = Request.ContentType;
            ViewBag.ContentType = getContentType;

            string getRequestUrl = Request.Url.ToString();
            ViewBag.Url = getRequestUrl;

            #endregion

            IdeaAppService service = new IdeaAppService();
            try
            {



                TempData["Error"] = "There is no error in ideas and Session value is" + Session[SessionConstants.USER_ID];

                if (Session[SessionConstants.USER_ID] != null)
                {



                    UserAppService objUserAppService = new UserAppService();
                    Int32 userId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());
                    Int32 homeNumber = 1;

                    if (Session[SessionConstants.HOME_NUMBER] == null || Convert.ToInt32(Session[SessionConstants.HOME_NUMBER]) == 0)
                    {
                        var getHomeNumber = objUserAppService.GetHomeNumber(userId);
                        homeNumber = getHomeNumber;
                        Session[SessionConstants.HOME_NUMBER] = homeNumber;
                    }
                    else
                        homeNumber = Convert.ToInt32(Session[SessionConstants.HOME_NUMBER].ToString());

                    string getRequestedMonth = System.DateTime.Now.Month.ToString();
                    string getRequestedYear = System.DateTime.Now.Year.ToString();




                    TasksRequest objIdeasRequest = new TasksRequest();
                    objIdeasRequest.UserId = userId;
                    objIdeasRequest.HomeNumber = Convert.ToByte(homeNumber);
                    objIdeasRequest.Month = Convert.ToByte(getRequestedMonth);
                    objIdeasRequest.Year = Convert.ToInt16(getRequestedYear);

                    var ideas = service.GetIdeaList(objIdeasRequest);

                    if (ideas.Count() == 0)
                    {
                        ViewBag.noRecords = "You have no Ideas for this month based on your personalization.";
                    }


                    // To Get User Home Name
                    PersonalisationAppService objPersonalisationAppService = new PersonalisationAppService();
                    GetUserHomeRequest objGetUserHomeRequest = new GetUserHomeRequest();
                    objGetUserHomeRequest.UserId = userId;
                    var getUserHome = (from d in objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest) where d.home_number == homeNumber select d).SingleOrDefault();
                    var getUserHome1 = objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest);
                    if (getUserHome1.Count > 1)
                    {
                        ViewBag.getSingleHomeName = getUserHome1.FirstOrDefault().home_name;
                        ViewBag.getHomeNameIdea = new SelectList(getUserHome1, "home_number", "home_name", homeNumber);
                    }
                    else
                    {
                        ViewBag.getSingleHomeName = null;
                        ViewBag.getHomeNameIdea = new SelectList(getUserHome1, "home_number", "home_name", homeNumber);
                    }

                    IdeasModel objIdeasModel = new IdeasModel();
                    var taskModels = new List<IdeasModel>();
                    objIdeasModel.listIdeasModel = ideas;
                    objIdeasModel.selectedmonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(getRequestedMonth));
                    objIdeasModel.selectedyear = Convert.ToInt32(getRequestedYear);

                    if (getUserHome == null)
                    {
                        objIdeasModel.homename = "";
                    }
                    else
                    {
                        objIdeasModel.homename = getUserHome.home_name;
                    }

                    return PartialView("ideas", objIdeasModel);

                }
                else
                {
                    //In Js function (mtt.js) we redirect blank content to Login Page.   
                    return Content("");
                }
            }
            catch (Exception err)
            {
                TempData["Error"] = err.Message;

                //return RedirectToAction("Login", "Home");
                return Content("");
            }
        }

        public ActionResult IdeasByHome(Int32? homeNumber)
        {
            IdeaAppService service = new IdeaAppService();
            try
            {

                   if (Session[SessionConstants.USER_ID] != null)
                {



                    UserAppService objUserAppService = new UserAppService();
                    Int32 userId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());
                    Session[SessionConstants.HOME_NUMBER] = homeNumber;

                  

                    string getRequestedMonth = System.DateTime.Now.Month.ToString();
                    string getRequestedYear = System.DateTime.Now.Year.ToString();




                    TasksRequest objIdeasRequest = new TasksRequest();
                    objIdeasRequest.UserId = userId;
                    objIdeasRequest.HomeNumber = Convert.ToByte(homeNumber);
                    objIdeasRequest.Month = Convert.ToByte(getRequestedMonth);
                    objIdeasRequest.Year = Convert.ToInt16(getRequestedYear);

                    var ideas = service.GetIdeaList(objIdeasRequest);

                    if (ideas.Count() == 0)
                    {
                        ViewBag.noRecords = "You have no Ideas for this month based on your personalization.";
                    }


                    // To Get User Home Name
                    PersonalisationAppService objPersonalisationAppService = new PersonalisationAppService();
                    GetUserHomeRequest objGetUserHomeRequest = new GetUserHomeRequest();
                    objGetUserHomeRequest.UserId = userId;
                    var getUserHome = (from d in objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest) where d.home_number == homeNumber select d).SingleOrDefault();
                    var getUserHome1 = objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest);
                    if (getUserHome1.Count > 1)
                    {
                        ViewBag.getSingleHomeName = getUserHome1.FirstOrDefault().home_name;
                        ViewBag.getHomeNameIdea = new SelectList(getUserHome1, "home_number", "home_name", homeNumber);
                    }
                    else
                    {
                        ViewBag.getSingleHomeName = null;
                        ViewBag.getHomeNameIdea = new SelectList(getUserHome1, "home_number", "home_name", homeNumber);
                    }

                    IdeasModel objIdeasModel = new IdeasModel();
                    var taskModels = new List<IdeasModel>();
                    objIdeasModel.listIdeasModel = ideas;
                    objIdeasModel.selectedmonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(getRequestedMonth));
                    objIdeasModel.selectedyear = Convert.ToInt32(getRequestedYear);

                    if (getUserHome == null)
                    {
                        objIdeasModel.homename = "";
                    }
                    else
                    {
                        objIdeasModel.homename = getUserHome.home_name;
                    }

                    return PartialView("ideas", objIdeasModel);

                }
                else
                {
                    //In Js function (mtt.js) we redirect blank content to Login Page.   
                    return Json("", JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception err)
            {
                

                //return RedirectToAction("Login", "Home");
                return Content("");
            }
        }

        public ActionResult IdeasView()
        {
            return View();
        }



        public SelectListItem[] getYears(Int32 startyear)
        {

            var result = new List<SelectListItem>();
            for (int i = startyear; i <= startyear + 9; i++)
            {
                result.Add(new SelectListItem
                {
                    Value = i.ToString(),
                    Text = i.ToString()
                });
            }
            return result.ToArray();

        }

        public JsonResult TaskDone(string taskCode, string month, string year, string status)
        {

            if (Session[SessionConstants.USER_ID] != null && Session[SessionConstants.HOME_NUMBER] != null)
            {
                TasksAppService service = new TasksAppService();
                DoneTaskRequest objDoneTaskRequest = new DoneTaskRequest();

                objDoneTaskRequest.UserId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());
                objDoneTaskRequest.HomeNumber = Convert.ToByte(Session[SessionConstants.HOME_NUMBER].ToString());

                objDoneTaskRequest.TaskCode = taskCode;
                objDoneTaskRequest.Month = Convert.ToByte(month);
                objDoneTaskRequest.Year = Convert.ToInt16(year);
                objDoneTaskRequest.Status = status;

                var getDoneTask = service.DoneTask(objDoneTaskRequest);
                return Json(getDoneTask, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(0, JsonRequestBehavior.AllowGet);
            }

        }



        public ActionResult ExtrasView()
        {
            //Session[SessionConstants.MODE] = ApplicationModeConstants.IPHONE_APP; //Only for Testing
            return View();
        }

        public ActionResult AdminView()
        {
            //Session[SessionConstants.MODE] = ApplicationModeConstants.IPHONE_APP; //Only for Testing
            return View();
        }


        public ActionResult TaskDetail(string taskCode)
        {
            //Session[SessionConstants.USER_ID] = null;
            //Session[SessionConstants.MODE] = ApplicationModeConstants.ANDROID_APP; //Only for Testing
            TasksAppService service = new TasksAppService();
            try
            {
                if (Session[SessionConstants.USER_ID] != null)
                {
                    Int32 userId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());
                    Int32 homeNumber = 1;

                    UserAppService objUserAppService = new UserAppService();
                    if (Session[SessionConstants.HOME_NUMBER] == null || Convert.ToInt32(Session[SessionConstants.HOME_NUMBER]) == 0)
                    {
                        var getHomeNumber = objUserAppService.GetHomeNumber(userId);
                        homeNumber = getHomeNumber;
                        Session[SessionConstants.HOME_NUMBER] = homeNumber;
                    }
                    else
                    {
                        homeNumber = Convert.ToInt32(Session[SessionConstants.HOME_NUMBER].ToString());
                    }


                    //Call Task App Service (GetTaskDetail)
                    TaskDetailRequest objTaskDetailRequest = new TaskDetailRequest();
                    objTaskDetailRequest.UserId = userId;
                    objTaskDetailRequest.HomeNumber = Convert.ToByte(homeNumber);
                    objTaskDetailRequest.TaskCode = taskCode.Trim();


                    //objTaskDetailRequest.UserId = 13577;
                    //objTaskDetailRequest.HomeNumber = Convert.ToByte(2);
                    //objTaskDetailRequest.TaskCode = "crc_21";

                    var taskDetail = service.GetTaskDetail(objTaskDetailRequest);
                    ViewBag.noRecords = "";
                    ViewBag.taskCodeStatus = taskCode.Trim();
                    //ViewBag.taskCodeStatus = "crc_21";
                    var taskDetailResult = (CTTaskDetailDto)taskDetail["TaskDetail"];


                    if (taskDetail["TaskDetail"] == null)
                    {
                        ViewBag.noRecords = "You have no Task Detail for this task based on your personalization.";
                    }

                    return PartialView("TaskDetail", taskDetailResult);
                }
                else
                {
                    //In Js function (mtt.js) we redirect blank content to Login Page.
                    return Json("", JsonRequestBehavior.AllowGet);
                }
            }
            catch
            {
                //return RedirectToAction("Login", "Home");
                return Json("", JsonRequestBehavior.AllowGet);
            }

        }

        public ActionResult TaskCustomize(string taskCode)
        {
            if (Session[SessionConstants.USER_ID] != null)
            {
                ViewBag.getTaskCode = taskCode;
                return PartialView();
            }
            else
                return Json("", JsonRequestBehavior.AllowGet);
        }

        public ActionResult TaskChange(string taskCode)
        {
            //Session[SessionConstants.USER_ID] = null;
            //Session[SessionConstants.HOME_NUMBER] = 2;


            TasksAppService service = new TasksAppService();
            if (Session[SessionConstants.USER_ID] != null)
            {
                Int32 userId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());
                Int32 homeNumber = 1;

                UserAppService objUserAppService = new UserAppService();
                if (Session[SessionConstants.HOME_NUMBER] == null || Convert.ToInt32(Session[SessionConstants.HOME_NUMBER]) == 0)
                {
                    var getHomeNumber = objUserAppService.GetHomeNumber(userId);
                    homeNumber = getHomeNumber;
                    Session[SessionConstants.HOME_NUMBER] = homeNumber;
                }
                else
                {
                    homeNumber = Convert.ToInt32(Session[SessionConstants.HOME_NUMBER].ToString());
                }


                //check taskcode contain CRC or not  //Get Custom Task

                CRC_Task_DetailsDto objCRC_Task_DetailsDto = new CRC_Task_DetailsDto();
                if (taskCode.ToLower().Contains("crc"))
                {
                    CRCTaskRequest objCRCTaskRequest = new CRCTaskRequest();
                    objCRCTaskRequest.UserId = userId;
                    objCRCTaskRequest.HomeNumber = Convert.ToByte(homeNumber);
                    objCRCTaskRequest.TaskCode = taskCode.Trim();
                    objCRC_Task_DetailsDto = service.GetCustomTask(objCRCTaskRequest);
                }
                else
                {
                    TaskDetailRequest objRequest = new TaskDetailRequest();
                    objRequest.UserId = userId;
                    objRequest.HomeNumber = Convert.ToByte(homeNumber);
                    objRequest.TaskCode = taskCode.Trim();
                    var getTaskDetail = service.GetTaskDetail(objRequest);
                    var taskDetailResult = (CTTaskDetailDto)getTaskDetail["TaskDetail"];

                    objCRC_Task_DetailsDto.user_id = userId;
                    objCRC_Task_DetailsDto.home_number = homeNumber;
                    objCRC_Task_DetailsDto.task_code = taskCode;




                    if (taskDetailResult != null)
                    {
                        objCRC_Task_DetailsDto.image = taskDetailResult.image;
                        objCRC_Task_DetailsDto.feature_name = taskDetailResult.feature_name;
                        objCRC_Task_DetailsDto.task_description = taskDetailResult.task_description;
                        objCRC_Task_DetailsDto.timing_months = taskDetailResult.timing_months;
                        objCRC_Task_DetailsDto.cycle_timing = taskDetailResult.cycle_timing;
                        objCRC_Task_DetailsDto.priority = taskDetailResult.priority;
                        objCRC_Task_DetailsDto.benefit_icons = taskDetailResult.benefit_icons;
                        objCRC_Task_DetailsDto.benefit_names = taskDetailResult.benefit_names;
                        objCRC_Task_DetailsDto.benefit_content = taskDetailResult.benefit_content;
                        if (taskDetailResult.energy_savings_score != null)
                        {
                            objCRC_Task_DetailsDto.energy_savings_score = taskDetailResult.energy_savings_score;
                        }
                        else {
                            objCRC_Task_DetailsDto.energy_savings_score = 0;
                        }
                        objCRC_Task_DetailsDto.energy_savings_content = taskDetailResult.energy_savings_content;
                        objCRC_Task_DetailsDto.cost_content = taskDetailResult.cost_content;
                        objCRC_Task_DetailsDto.type = taskDetailResult.type;
                        objCRC_Task_DetailsDto.cost_score = taskDetailResult.cost_score;
                    }

                }
                //Bind Dropdowns
                if (objCRC_Task_DetailsDto != null && objCRC_Task_DetailsDto.type != null)
                {
                    ViewBag.getType = new SelectList(GetTypes(), "Value", "Text", objCRC_Task_DetailsDto.type);
                }
                else
                {
                    ViewBag.getType = new SelectList(GetTypes(), "Value", "Text", 1);
                }

                if (objCRC_Task_DetailsDto != null && objCRC_Task_DetailsDto.priority != null)
                {
                    ViewBag.getPriority = new SelectList(GetPriorityCostEnergySavings(), "Value", "Text", objCRC_Task_DetailsDto.priority);
                }
                else
                {
                    ViewBag.getPriority = new SelectList(GetPriorityCostEnergySavings(), "Value", "Text", 1);
                }

                if (objCRC_Task_DetailsDto != null && objCRC_Task_DetailsDto.cost_score != null)
                {
                    ViewBag.getCostScore = new SelectList(GetPriorityCostEnergySavings(), "Value", "Text", objCRC_Task_DetailsDto.cost_score);
                }
                else
                {
                    ViewBag.getCostScore = new SelectList(GetPriorityCostEnergySavings(), "Value", "Text", 1);
                }

                if (objCRC_Task_DetailsDto != null && objCRC_Task_DetailsDto.energy_savings_score != null)
                {
                    ViewBag.getEnergySavings = new SelectList(GetPriorityCostEnergySavings(), "Value", "Text", objCRC_Task_DetailsDto.energy_savings_score);
                }
                else
                {
                    ViewBag.getEnergySavings = new SelectList(GetPriorityCostEnergySavings(), "Value", "Text", 1);
                }

                if (objCRC_Task_DetailsDto != null && objCRC_Task_DetailsDto.cycle_timing != null)
                {
                    ViewBag.getCycle = new SelectList(GetCycle(), "Value", "Text", objCRC_Task_DetailsDto.cycle_timing);
                }
                else
                {
                    ViewBag.getCycle = new SelectList(GetCycle(), "Value", "Text", 1);
                }
                //Bind Homes
                PersonalisationAppService objPersonalisationAppService = new PersonalisationAppService();
                GetUserHomeRequest objGetUserHomeRequest = new GetUserHomeRequest();
                objGetUserHomeRequest.UserId = userId;
                var getUserHome = objPersonalisationAppService.GetUserHomes(objGetUserHomeRequest);
                if (getUserHome != null)
                {

                    if (getUserHome.Count == 1)
                    {
                        ViewBag.getSingleHomeName = getUserHome.FirstOrDefault().home_name;
                    }
                    else
                    {
                        ViewBag.getSingleHomeName = null;
                    }


                    if (objCRC_Task_DetailsDto != null && objCRC_Task_DetailsDto.home_number != 0)
                    {
                        ViewBag.getHomeName = new SelectList(getUserHome, "home_number", "home_name", objCRC_Task_DetailsDto.home_number);
                    }
                    else
                    {
                        ViewBag.getHomeName = new SelectList(getUserHome, "home_number", "home_name", 0);
                    }
                }

                //bind Task code with current Task code

                //Bind Months
                ViewBag.Months = getMonths();

                //Bind Benefits
                var getBenefits = service.GetBenefitIconUrls();
                ViewBag.Benefits = getBenefits;

                return PartialView(objCRC_Task_DetailsDto);

            }
            else
            {

                return Json("", JsonRequestBehavior.AllowGet);
            }



        }


        public ActionResult UpdateCustomTask(CRC_Task_DetailsDto model)
        {
            //Session[SessionConstants.USER_ID] = 13577;
            //Session[SessionConstants.HOME_NUMBER] = 2;


            var taskCode = model.task_code;
            TasksAppService service = new TasksAppService();
            if (Session[SessionConstants.USER_ID] != null)
            {
                Int32 userId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());
                Int32 homeNumber = 1;

                UserAppService objUserAppService = new UserAppService();
                if (Session[SessionConstants.HOME_NUMBER] == null || Convert.ToInt32(Session[SessionConstants.HOME_NUMBER]) == 0)
                {
                    var getHomeNumber = objUserAppService.GetHomeNumber(userId);
                    homeNumber = getHomeNumber;
                    Session[SessionConstants.HOME_NUMBER] = homeNumber;
                }
                else
                {
                    homeNumber = Convert.ToInt32(Session[SessionConstants.HOME_NUMBER].ToString());
                }

                CRCTaskRequest objCRCTaskRequest = new CRCTaskRequest();
                objCRCTaskRequest.UserId = userId;
                objCRCTaskRequest.HomeNumber = Convert.ToByte(homeNumber);
                objCRCTaskRequest.TaskCode = taskCode;

                objCRCTaskRequest.Image = model.image;
                objCRCTaskRequest.FeatureName = model.feature_name;
                objCRCTaskRequest.TaskDescription = model.task_description;
                objCRCTaskRequest.TimingMonths = model.timing_months;
                if (model.cycle_timing != null)
                {
                    objCRCTaskRequest.CycleTiming = Convert.ToInt32(model.cycle_timing);
                }

                if (model.priority != null)
                {
                    objCRCTaskRequest.Priority = Convert.ToInt32(model.priority);
                }
                objCRCTaskRequest.BenefitIcons = model.benefit_icons;
                objCRCTaskRequest.BenefitNames = model.benefit_names;
                objCRCTaskRequest.BenefitContent = model.benefit_content;

                if (model.energy_savings_score != null)
                {

                    objCRCTaskRequest.EnergySavingsScore = Convert.ToInt32(model.energy_savings_score);
                }
                objCRCTaskRequest.EnergySavingsContent = model.energy_savings_content;

                if (model.cost_score != null)
                {
                    objCRCTaskRequest.CostScore = Convert.ToInt32(model.cost_score);
                }
                objCRCTaskRequest.CostContent = model.cost_content;

                if (model.type != null)
                {
                    objCRCTaskRequest.Type = Convert.ToInt32(model.type);
                }

                if (taskCode.ToLower().Contains("crc"))
                {
                    //1.) Custom Task(CRC)(If taskId DOES begin with “CRC”, then update this taskId in the “CRC_Task_Details” table)
                    service.UpdateCustomTask(objCRCTaskRequest);
                    return RedirectToAction("TasksView");

                }
                else
                {

                    //2.) Simple Task (If taskId does NOT begin with “CRC” then when user clicks “save”, add the taskId to the“deleted tasks” table, and add a new record to the “CRC_Task_Details” table.)

                    TurnOffTaskRequest objTurnOffTaskRequest = new TurnOffTaskRequest();
                    objTurnOffTaskRequest.UserId = userId;
                    objTurnOffTaskRequest.HomeNumber = Convert.ToByte(homeNumber);
                    objTurnOffTaskRequest.TaskCode = taskCode;

                    string getResultTurnOffTask = service.TurnOffTask(objTurnOffTaskRequest);
                    if (getResultTurnOffTask == "Success")
                    {
                        service.CreateCustomTask(objCRCTaskRequest);
                    }
                    return RedirectToAction("TasksView");
                }


            }
            else
            {
                return RedirectToAction("Login", "Home");
            }

        }

        public ActionResult DeleteTask(string id)
        {
            TasksAppService service = new TasksAppService();
            if (Session[SessionConstants.USER_ID] != null)
            {
                Int32 userId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());
                Int32 homeNumber = 0;

                UserAppService objUserAppService = new UserAppService();
                if (Session[SessionConstants.HOME_NUMBER] == null || Convert.ToInt32(Session[SessionConstants.HOME_NUMBER]) == 0)
                {
                    var getHomeNumber = objUserAppService.GetHomeNumber(userId);
                    homeNumber = getHomeNumber;
                    Session[SessionConstants.HOME_NUMBER] = homeNumber;
                }
                else
                {
                    homeNumber = Convert.ToInt32(Session[SessionConstants.HOME_NUMBER].ToString());
                }
                TurnOffTaskRequest objTurnOffTaskRequest = new TurnOffTaskRequest();
                objTurnOffTaskRequest.UserId = userId;
                objTurnOffTaskRequest.HomeNumber = Convert.ToByte(homeNumber);
                objTurnOffTaskRequest.TaskCode = id;
                string getResultTurnOffTask = service.TurnOffTask(objTurnOffTaskRequest);

                return RedirectToAction("TasksView");

            }
            else
            {

                return RedirectToAction("Login", "Home");
            }

        }

        public ActionResult DeleteEntireFeature(string featureString)
        {
            TasksAppService service = new TasksAppService();
            if (Session[SessionConstants.USER_ID] != null)
            {
                Int32 userId = Convert.ToInt32(Session[SessionConstants.USER_ID].ToString());
                Int32 homeNumber = 0;

                UserAppService objUserAppService = new UserAppService();
                if (Session[SessionConstants.HOME_NUMBER] == null || Convert.ToInt32(Session[SessionConstants.HOME_NUMBER]) == 0)
                {
                    var getHomeNumber = objUserAppService.GetHomeNumber(userId);
                    homeNumber = getHomeNumber;
                    Session[SessionConstants.HOME_NUMBER] = homeNumber;
                }
                else
                {
                    homeNumber = Convert.ToInt32(Session[SessionConstants.HOME_NUMBER].ToString());
                }

                bool getResultTurnOffTask = service.DeleteEntireFeature(userId, homeNumber, featureString);

                return RedirectToAction("TasksView");

            }
            else
            {

                return RedirectToAction("Login", "Home");
            }
        }

        #region[Common Functions]
        public SelectListItem[] GetTypes()
        {
            return new[]
            {
               new SelectListItem { Value = "1", Text = "Inside" },
               new SelectListItem { Value = "2", Text = "Outside" },
               new SelectListItem { Value = "3", Text = "Other" }
            };

        }
        public SelectListItem[] GetPriorityCostEnergySavings()
        {
            return new[]
            {
                 new SelectListItem { Value = "5", Text = "5" },
                 new SelectListItem { Value = "4", Text = "4" },
                 new SelectListItem { Value = "3", Text = "3" },
                 new SelectListItem { Value = "2", Text = "2" },
                 new SelectListItem { Value = "1", Text = "1" }
             };

        }

        public SelectListItem[] GetCycle()
        {
            return new[]
            {
               new SelectListItem { Value = "1", Text = "yearly" },
               new SelectListItem { Value = "2", Text = "every 2 years" },
               new SelectListItem { Value = "3", Text = "every 3 years" },
               new SelectListItem { Value = "4", Text = "every 4 years" },
               new SelectListItem { Value = "5", Text = "every 5 years" },
               new SelectListItem { Value = "6", Text = "every 6 years" },
               new SelectListItem { Value = "7", Text = "every 7 years" },
               new SelectListItem { Value = "8", Text = "every 8 years" },
               new SelectListItem { Value = "9", Text = "every 9 years" },
               new SelectListItem { Value = "10", Text = "every 10 years" },
               new SelectListItem { Value = "11", Text = "every 11 years" },
               new SelectListItem { Value = "12", Text = "every 12 years" },
               new SelectListItem { Value = "13", Text = "every 13 years" },
               new SelectListItem { Value = "14", Text = "every 14 years" },
               new SelectListItem { Value = "15", Text = "every 15 years" },
               new SelectListItem { Value = "16", Text = "every 16 years" },
               new SelectListItem { Value = "17", Text = "every 17 years" },
               new SelectListItem { Value = "18", Text = "every 18 years" },
               new SelectListItem { Value = "19", Text = "every 19 years" },
               new SelectListItem { Value = "20", Text = "every 20 years" }
              
            };

        }

        public SelectListItem[] getMonths()
        {
            return new[]
        {
           new SelectListItem { Value = "1", Text = "January" },
           new SelectListItem { Value = "2", Text = "February" },
           new SelectListItem { Value = "3", Text = "March" },
           new SelectListItem { Value = "4", Text = "April" },
           new SelectListItem { Value = "5", Text = "May" },
           new SelectListItem { Value = "6", Text = "June" },
           new SelectListItem { Value = "7", Text = "July" },
           new SelectListItem { Value = "8", Text = "August" },
           new SelectListItem { Value = "9", Text = "September" },
           new SelectListItem { Value = "10", Text = "October" },
           new SelectListItem { Value = "11", Text = "November" },
           new SelectListItem { Value = "12", Text = "December" },
        };

        }

        public SelectListItem[] getDisplay()
        {
            return new[]
        {
            new SelectListItem{Value="N",Text="Still To Do"},
            new SelectListItem{Value="Y",Text="Done"},
            new SelectListItem{Value="",Text="All"},
        };
        }
        public SelectListItem[] getSortBy()
        {
            return new[]
        {
            new SelectListItem{Value="1",Text="Priority"},
            new SelectListItem{Value="2",Text="Home Feature"},
            //new SelectListItem{Value="3",Text="Benefits"},
            new SelectListItem{Value="4",Text="Type (Indoor-Outdoor-Other)"},
        };
        }

        #endregion


    }
}
